using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using RetailAnalytic.Core;

namespace RetailAnalytic.DM.Engine
{
    public partial class FrmNP : RetailAnalytic.Core.FrmNPTemplate
    {
        private bool _isProperties;
        ICrViewPropPresentation sp;
        public FrmNP()
        {
            InitializeComponent();
        }
        public FrmNP(PresentationBase presentationBase, bool isProperties)
        {
            RunProgress.Start();
            this._isProperties = isProperties;
            InitializeComponent();
            sp = (ICrViewPropPresentation)new GUISupport(presentationBase, isProperties);
            SetCurrUC(0);
            lvSel.Items[4].Visible = false;
            this.Text = sp.Names;
            RunProgress.Stop();
        }
        private void ultraButton1_Click_1(object sender, EventArgs e)
        {
            string ExtendStatusMessage;
            if (sp.TestCanSave(true, out ExtendStatusMessage))
            {
                if (sp.Save())
                {
                    Close();
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    sp.Cancel();
                    Close();
                    this.DialogResult = DialogResult.Cancel;
                }
            }
        }
        public Int32 NewClassTaskID
        {
            get
            {
                return ((GUISupport)sp).presentationBase.ClassTaskID;
            }
        }
        private void ultraButton2_Click_1(object sender, EventArgs e)
        {
            if (Dialog.Show(Dialog_type.Question, SR.StringLibrary.GetStrMSG(SR.StringLibrary.KeyEnum.Ask_IS_EXIT_WO_SAVE,
                Environment.StackTrace, ""),
                new ButtonDialog[] { ButtonDialog.Button_yes, ButtonDialog.Button_no }) == ButtonDialog.Button_yes)
            {
                sp.Cancel();
                Close();
                this.DialogResult = DialogResult.Cancel;
            }
        }
        private void lvSel_ItemActivated(object sender, Infragistics.Win.UltraWinListView.ItemActivatedEventArgs e)
        {
            SetCurrUC(e.Item.Index);
        }
        public void SetCurrUC(int iUC)
        {
            PanelContainer.Controls.Clear();
            UserControl currUC = sp.SelectCurrGuiParts(iUC);
            currUC.Dock = DockStyle.Fill;
            currUC.Parent = PanelContainer;
            currUC.Show();
        }
        public void FrmNP_Validated(object sender, EventArgs e)
        {
            string ExtendStatusMessage;
            this.SetStatus(!sp.TestCanSave(false, out ExtendStatusMessage));
            this.SetExtendStatusMessage = ExtendStatusMessage;
        }
    }
}